home *** CD-ROM | disk | FTP | other *** search
/ Chip 2011 November / CHIP_2011_11.iso / Programy / Inne / Gry / Carnage_Contest / scripts / CC Original / tools / The Stake.lua < prev    next >
Text File  |  2010-09-16  |  2KB  |  78 lines

  1. --------------------------------------------------------------------------------
  2. -- Weapon The Stake Of Inquisition
  3. -- Original Carnage Contest Weapon
  4. -- Script by DC, September 2010, www.UnrealSoftware.de
  5. --------------------------------------------------------------------------------
  6.  
  7. -- Setup Tables
  8. if cc==nil then cc={} end
  9. cc.stake={}
  10. cc.stake.spawn={}
  11.  
  12. -- Load & Prepare Ressources
  13. cc.stake.gfx_wpn=loadgfx("buildings/thestake.bmp")                    -- Weapon Image
  14. setmidhandle(cc.stake.gfx_wpn)
  15. cc.stake.sfx_build=loadsfx("buildwood.ogg")                            -- Build Sound
  16. cc.stake.sfx_church=loadsfx("church.ogg")                            -- Church Sound
  17.  
  18. --------------------------------------------------------------------------------
  19. -- Weapon: The Stake Of Inquisition
  20. --------------------------------------------------------------------------------
  21.  
  22. cc.stake.id=addweapon("cc.stake","The Stake of Inquisition",cc.stake.gfx_wpn,0)            -- Add Weapon (0 uses)
  23.  
  24. function cc.stake.draw()                                                -- Draw
  25.     -- HUD Positioning
  26.     if weapon_shots==0 then
  27.         hudpositioning(pos_build,cc.stake.gfx_wpn,150,0,0,1)
  28.     end
  29. end
  30.  
  31. function cc.stake.attack(attack)                                        -- Attack
  32.     if (weapon_shots<=0) and (weapon_position==1) then
  33.         -- Use weapon
  34.         useweapon(0)
  35.         weapon_shots=weapon_shots+1
  36.         -- Draw
  37.         terrainimage(cc.stake.gfx_wpn,weapon_x,weapon_y)
  38.         -- Sound
  39.         playsound(cc.stake.sfx_build)
  40.         playsound(cc.stake.sfx_church)
  41.         -- Firespwaner
  42.         id=createprojectile(cc.stake.spawn.id)
  43.         projectiles[id]={}
  44.         projectiles[id].x=weapon_x
  45.         projectiles[id].y=weapon_y
  46.         projectiles[id].timer=120
  47.         projectiles[id].counter=0
  48.         -- End Turn
  49.         endturn()
  50.     end
  51. end
  52.  
  53. --------------------------------------------------------------------------------
  54. -- Projectile: Firespawner
  55. --------------------------------------------------------------------------------
  56.  
  57. cc.stake.spawn.id=addprojectile("cc.stake.spawn")                        -- Add Projectile
  58.  
  59. function cc.stake.spawn.draw(id)                                        -- Draw
  60.     -- Do Nothing!
  61. end
  62.  
  63. function cc.stake.spawn.update(id)                                        -- Update
  64.     -- Countdown
  65.     projectiles[id].timer=projectiles[id].timer-1
  66.     if projectiles[id].timer<=0 then
  67.         -- Spawn Fire
  68.         for i=-1,1 do
  69.             createobject(o_fire,projectiles[id].x+i*5,projectiles[id].y+20+math.random(0,3))
  70.         end
  71.         projectiles[id].counter=projectiles[id].counter+1
  72.         projectiles[id].timer=150
  73.         if projectiles[id].counter>2 then
  74.             -- Free projectile
  75.             freeprojectile(id)
  76.         end
  77.     end
  78. end